# coding=utf-8
import socket
import datetime


# [2021-08-16_15_05_01] 10.33.131.1033:9030 is Not Available
# [2021-08-16_15_05_01] 10.33.131.102:9030 is Available

def net_is_used():
    doris_conns = {
        "doris1": "10.33.131.101",
        "doris2": "10.33.131.102",
        "doris3": "10.33.131.103",
    }
    # port = 9030
    # s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    # for index in doris_conns:
    #     ip = doris_conns.get(index)
    #     try:
    #         s.connect((ip, port))
    #         s.shutdown(2)
    #         print('[{}] {}:{} is Available'.format((datetime.datetime.now().strftime("%F %H:%M:%S")), ip, port))
    #         return index
    #     except:
    #         print('[{}] {}:{} is Not Available'.format((datetime.datetime.now().strftime("%F %H:%M:%S")), ip, port))
    #         continue
    print('[{}] {}:{} is Not Available'.format((datetime.datetime.now().strftime("%F %H:%M:%S")), "doris1", 9030))
    return "doris"
